package com.bdqn.appjob.service.backend;

import javax.annotation.Resource;

import com.bdqn.appjob.dao.backend.BackBackendMapper;
import org.springframework.stereotype.Service;

import com.bdqn.appjob.dao.backend.BackBackendMapper;
import com.bdqn.appjob.entity.BackendUser;

@Service("backendService")
public class BackBackendServiceImpl implements BackBackendService {
	@Resource
	private BackBackendMapper backbackendMapper;

	@Override
	public BackendUser login(String userCode, String userPassword) {
		BackendUser user = null;
		try {
			user = backbackendMapper.login(userCode);
		} catch (Exception e) {
			e.printStackTrace();
		}
		//判断密码是否正确
		if(user != null){		//不等于空就是查到用户了
			if(userPassword.equals(user.getUserPassword())){
				return user;	//根据用户判断密码
			}else{
				throw new RuntimeException("密码输入错误!");
			}
		}else{
			throw new RuntimeException("用户名不存在!");
		}
	}

}
